home *** CD-ROM | disk | FTP | other *** search
/ IRIX 6.3 Development Libraries / SGI IRIX 6.3 Development Libraries.iso / dist6.3 / ViewKit_dev.idb / usr / include / Vk / VkDialogManager.h.z / VkDialogManager.h
Encoding:
C/C++ Source or Header  |  1996-09-20  |  15.8 KB  |  438 lines

  1. ////////////////////////////////////////////////////////////////////////////////
  2. ///////   Copyright 1992, Silicon Graphics, Inc.  All Rights Reserved.   ///////
  3. //                                                                            //
  4. // This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;     //
  5. // the contents of this file may not be disclosed to third parties, copied    //
  6. // or duplicated in any form, in whole or in part, without the prior written  //
  7. // permission of Silicon Graphics, Inc.                                       //
  8. //                                                                            //
  9. // RESTRICTED RIGHTS LEGEND:                                                  //
  10. // Use,duplication or disclosure by the Government is subject to restrictions //
  11. // as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data     //
  12. // and Computer Software clause at DFARS 252.227-7013, and/or in similar or   //
  13. // successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -    //
  14. // rights reserved under the Copyright Laws of the United States.             //
  15. //                                                                            //
  16. ////////////////////////////////////////////////////////////////////////////////
  17.  
  18.  
  19. #ifndef VKDIALOGMANAGER_H
  20. #define VKDIALOGMANAGER_H
  21.  
  22. #include <Vk/VkComponent.h>
  23. #include <Vk/VkWidgetList.h>
  24.  
  25. class VkSimpleWindow;
  26. class VkDialog;
  27.  
  28.  
  29. class VkDialogManager : public VkComponent {
  30.  
  31.   public:
  32.  
  33.     enum VkDialogReason { CANCEL, OK, APPLY, NONE };
  34.  
  35.    protected:
  36.  
  37.     VkDialogReason _action;
  38.     Boolean _showOK, _showCancel, _showApply;
  39.     Boolean _allowMultipleDialogs;
  40.     Boolean _minimizeMultipleDialogs;
  41.  
  42.     virtual void setUpWindowManagerProperties(Widget w);
  43.  
  44.     Widget prepost ( const char *, 
  45.              const char  *,                
  46.              VkSimpleWindow *);                 
  47.  
  48.  
  49.     virtual Widget prepost ( const char      *message, 
  50.                  XtCallbackProc   okCB       = NULL, 
  51.                  XtCallbackProc   cancelCB   = NULL, 
  52.                  XtCallbackProc   applyCB    = NULL, 
  53.                  XtPointer        clientData = NULL,
  54.                  const char      *helpString = NULL,
  55.                  VkSimpleWindow  *parent     = NULL);
  56.  
  57.     void waitForDialog(Widget, VkSimpleWindow *, Widget);
  58.  
  59.     virtual void ok(Widget, XtPointer);
  60.     virtual void cancel(Widget, XtPointer);
  61.     virtual void apply(Widget, XtPointer);
  62.  
  63.     virtual Widget createDialog(Widget parent) = 0;
  64.  
  65.     VkDialogManager(const char *);
  66.  
  67.    public:
  68.  
  69.     virtual ~VkDialogManager();
  70.     const char * className();
  71.  
  72.     Widget lastPosted();
  73.  
  74.     void setTitle(const char *nextTitle = NULL);
  75.     void setButtonLabels(const char *ok = NULL, const char *cancel = NULL, const char * apply = NULL);
  76.  
  77.     static const char *const prepostCallback;
  78.  
  79.     void unpost();
  80.     void unpost(Widget w);
  81.     void unpostAll();
  82.  
  83.     void centerOnScreen(Boolean flag) { _centerMode = flag; }
  84.  
  85.     virtual void hide();  // Same as unpost
  86.     virtual void show();  // alias for post( /* no args */ )
  87.  
  88.     
  89.     // Derived class that want to modify post behavior should override only these functions
  90.  
  91.     virtual Widget post ( const char      *message    = NULL, 
  92.               XtCallbackProc   okCB       = NULL, 
  93.               XtCallbackProc   cancelCB   = NULL, 
  94.               XtCallbackProc   applyCB    = NULL, 
  95.               XtPointer        clientData = NULL,
  96.               const char      *helpString = NULL,                
  97.                VkSimpleWindow  *parent     = NULL,
  98.               Widget           parentWidget = NULL);
  99.  
  100.  
  101.     virtual Widget postModal ( const char      *message    = NULL, 
  102.                    XtCallbackProc   okCB       = NULL, 
  103.                    XtCallbackProc   cancelCB   = NULL, 
  104.                    XtCallbackProc   applyCB    = NULL, 
  105.                    XtPointer        clientData = NULL,
  106.                    const char      *helpString = NULL,                
  107.                    VkSimpleWindow  *parent     = NULL,
  108.                    Widget           parentWidget = NULL);                   
  109.  
  110.  
  111.     virtual Widget postBlocked ( const char      *message    = NULL, 
  112.                  XtCallbackProc   okCB       = NULL, 
  113.                  XtCallbackProc   cancelCB   = NULL, 
  114.                  XtCallbackProc   applyCB    = NULL, 
  115.                  XtPointer        clientData = NULL,
  116.                  const char      *helpString = NULL,                
  117.                  VkSimpleWindow  *parent     = NULL,
  118.                  Widget           parentWidget = NULL);                                    
  119.  
  120.  
  121.     virtual VkDialogReason postAndWait ( const char      *message    = NULL, 
  122.                          int          ok         = -1, 
  123.                          int          cancel     = -1, 
  124.                          int          apply      = -1, 
  125.                          const char      *helpString = NULL,                
  126.                          VkSimpleWindow  *parent     = NULL,
  127.                      Widget           parentWidget = NULL);
  128.  
  129.   // These are conveniences
  130.  
  131.     Widget post ( const char *msg, 
  132.           VkSimpleWindow *parent) { return post(msg, NULL, NULL,
  133.                                NULL, NULL, NULL, parent); }
  134.  
  135.     Widget post ( const char *msg, 
  136.           Widget parent) {   return post(msg, NULL, NULL,
  137.                          NULL, NULL, NULL, NULL, parent); }    
  138.  
  139.     Widget post ( const char     *msg, 
  140.           const char     *helpString,                
  141.           VkSimpleWindow *parent) { return post(msg, NULL,
  142.                             NULL, NULL, NULL, helpString, parent); }
  143.  
  144.     Widget post ( const char     *msg, 
  145.           const char     *helpString,                
  146.           Widget parent) { return post(msg, NULL, NULL,
  147.                            NULL, NULL, helpString, NULL, parent); }    
  148.  
  149.     Widget post ( const char      *msg, 
  150.           XtCallbackProc   okCB, 
  151.           XtPointer        clientData,
  152.           VkSimpleWindow  *parent = NULL)  { return post(msg, okCB,
  153.                                  NULL, NULL, clientData, NULL, parent); }
  154.  
  155.     Widget post ( const char      *msg, 
  156.           XtCallbackProc   okCB, 
  157.           XtPointer        clientData,
  158.           Widget           parent)  { return post(msg, okCB, NULL, NULL,
  159.                              clientData, NULL, NULL, parent); }    
  160.  
  161.     Widget post ( const char      *msg, 
  162.           XtCallbackProc   okCB, 
  163.           XtPointer        clientData,
  164.           const char     *helpString,                
  165.           VkSimpleWindow  *parent = NULL)  { return post(msg, okCB, NULL, NULL,
  166.                                  clientData, helpString, parent); }
  167.  
  168.     Widget post ( const char      *msg, 
  169.           XtCallbackProc   okCB, 
  170.           XtPointer        clientData,
  171.           const char     *helpString,                
  172.           Widget          parent)  { return post(msg, okCB, NULL,
  173.                              NULL, clientData, helpString, NULL, parent); }    
  174.  
  175.  
  176.    Widget post ( const char     *msg, 
  177.          XtCallbackProc  okCB, 
  178.          XtCallbackProc  cancelCB, 
  179.          XtPointer       clientData,
  180.          VkSimpleWindow *parent = NULL)  { return post(msg, okCB, cancelCB,
  181.                                    NULL, clientData, NULL, parent); }
  182.  
  183.     Widget post ( const char     *msg, 
  184.           XtCallbackProc  okCB, 
  185.           XtCallbackProc  cancelCB, 
  186.           XtPointer        clientData,
  187.           Widget parent)  { return post(msg, okCB, cancelCB,
  188.                         NULL, clientData, NULL, NULL, parent); }    
  189.  
  190.    Widget post ( const char     *msg, 
  191.          XtCallbackProc  okCB, 
  192.          XtCallbackProc  cancelCB, 
  193.          XtPointer       clientData,
  194.          char            *helpString,
  195.          VkSimpleWindow *parent = NULL)  { return post(msg, okCB, cancelCB, NULL, clientData, helpString, parent); }
  196.  
  197.     Widget post ( const char     *msg, 
  198.           XtCallbackProc  okCB, 
  199.           XtCallbackProc  cancelCB, 
  200.           XtPointer       clientData,
  201.           char            *helpString,
  202.           Widget          parent)  { return post(msg, okCB, cancelCB, NULL,
  203.                              clientData, helpString, NULL, parent); }    
  204.  
  205.    Widget post ( const char  *msg, 
  206.           XtCallbackProc  okCB, 
  207.           XtCallbackProc  cancelCB, 
  208.           XtCallbackProc  applyCB, 
  209.           XtPointer       clientData,
  210.           VkSimpleWindow *parent)  { return post(msg, okCB, cancelCB,
  211.                              applyCB, clientData, NULL, parent); }
  212.  
  213.    Widget post ( const char     *msg, 
  214.          XtCallbackProc  okCB, 
  215.          XtCallbackProc  cancelCB, 
  216.          XtCallbackProc  applyCB, 
  217.          XtPointer       clientData,
  218.          Widget parent)  { return post(msg, okCB, cancelCB, applyCB, clientData, NULL, NULL, parent); }    
  219.  
  220.  
  221.   // Modal
  222.  
  223.   Widget postModal ( const char *msg, 
  224.              VkSimpleWindow *parent) { return postModal(msg, NULL, NULL, NULL, NULL, NULL, parent); }
  225.   
  226.   Widget postModal ( const char     *msg, 
  227.              const char     *helpString,                
  228.              VkSimpleWindow *parent) { return postModal(msg, NULL, NULL, NULL, NULL, helpString, parent); }
  229.  
  230.   Widget postModal ( const char      *msg, 
  231.              XtCallbackProc   okCB, 
  232.              XtPointer        clientData,
  233.              VkSimpleWindow  *parent = NULL)  { return postModal(msg, okCB, NULL, NULL, clientData, NULL, parent); }
  234.  
  235.   Widget postModal ( const char      *msg, 
  236.              XtCallbackProc   okCB, 
  237.              XtPointer       clientData,
  238.              const char     *helpString,                
  239.              VkSimpleWindow  *parent = NULL)  { return postModal(msg, okCB, NULL, NULL, clientData, helpString, parent); }
  240.  
  241.  
  242.   Widget postModal ( const char     *msg, 
  243.              XtCallbackProc  okCB, 
  244.              XtCallbackProc  cancelCB, 
  245.              XtPointer       clientData,
  246.              VkSimpleWindow *parent = NULL)  { return postModal(msg, okCB, cancelCB, NULL, clientData, NULL, parent); }
  247.  
  248.   Widget postModal ( const char     *msg, 
  249.              XtCallbackProc  okCB, 
  250.              XtCallbackProc  cancelCB, 
  251.              XtPointer       clientData,
  252.              char            *helpString,
  253.              VkSimpleWindow *parent = NULL)  { return postModal(msg, okCB, cancelCB, NULL, clientData, helpString, parent); }
  254.  
  255.   Widget postModal ( const char     *msg, 
  256.              XtCallbackProc  okCB, 
  257.              XtCallbackProc  cancelCB, 
  258.              XtCallbackProc  applyCB, 
  259.              XtPointer       clientData,
  260.              VkSimpleWindow *parent)  { return postModal(msg, okCB, cancelCB, applyCB, clientData, NULL, parent); }
  261.  
  262.   Widget postModal ( const char *msg, 
  263.              Widget parent) { return postModal(msg, NULL, NULL, NULL, NULL, NULL, NULL, parent); }
  264.   
  265.   Widget postModal ( const char     *msg, 
  266.              const char     *helpString,                
  267.              Widget parent) { return postModal(msg, NULL, NULL, NULL, NULL, helpString, NULL, parent); }
  268.  
  269.   Widget postModal ( const char      *msg, 
  270.              XtCallbackProc   okCB, 
  271.              XtPointer        clientData,
  272.              Widget parent)  { return postModal(msg, okCB, NULL, NULL, clientData, NULL, NULL, parent); }
  273.  
  274.   Widget postModal ( const char      *msg, 
  275.              XtCallbackProc   okCB, 
  276.              XtPointer       clientData,
  277.              const char     *helpString,                
  278.              Widget parent)  { return postModal(msg, okCB, NULL, NULL, clientData, helpString, NULL, parent); }
  279.  
  280.   Widget postModal ( const char     *msg, 
  281.              XtCallbackProc  okCB, 
  282.              XtCallbackProc  cancelCB, 
  283.              XtPointer       clientData,
  284.              Widget parent)  { return postModal(msg, okCB, cancelCB, NULL, clientData, NULL, NULL, parent); }
  285.  
  286.   Widget postModal ( const char     *msg, 
  287.              XtCallbackProc  okCB, 
  288.              XtCallbackProc  cancelCB, 
  289.              XtPointer       clientData,
  290.              char            *helpString,
  291.              Widget parent)  { return postModal(msg, okCB, cancelCB, NULL, clientData, helpString, NULL, parent); }
  292.  
  293.   Widget postModal ( const char     *msg, 
  294.              XtCallbackProc  okCB, 
  295.              XtCallbackProc  cancelCB, 
  296.              XtCallbackProc  applyCB, 
  297.              XtPointer       clientData,
  298.              Widget parent)  { return postModal(msg, okCB, cancelCB, applyCB, clientData, NULL, NULL, parent); }    
  299.  
  300.  
  301. // Blocked
  302.  
  303.   Widget postBlocked ( const char *msg, 
  304.                VkSimpleWindow *parent) { return postBlocked(msg, NULL, NULL, NULL, NULL, NULL, parent); }
  305.   
  306.   Widget postBlocked ( const char     *msg, 
  307.                const char     *helpString,                
  308.                VkSimpleWindow *parent) { return postBlocked(msg, NULL, NULL, NULL, NULL, helpString, parent); }
  309.  
  310.   Widget postBlocked ( const char      *msg, 
  311.                XtCallbackProc   okCB, 
  312.                XtPointer        clientData,
  313.                VkSimpleWindow  *parent = NULL)  { return postBlocked(msg, okCB, NULL, NULL, clientData, NULL, parent); }
  314.  
  315.   Widget postBlocked ( const char      *msg, 
  316.                XtCallbackProc   okCB, 
  317.                XtPointer        clientData,
  318.                const char     *helpString,                
  319.                VkSimpleWindow  *parent = NULL)  { return postBlocked(msg, okCB, NULL, NULL, clientData, helpString, parent); }
  320.  
  321.  
  322.   Widget postBlocked ( const char     *msg, 
  323.                XtCallbackProc  okCB, 
  324.                XtCallbackProc  cancelCB, 
  325.                XtPointer       clientData,
  326.                VkSimpleWindow *parent = NULL)  { return postBlocked(msg, okCB, cancelCB, NULL, clientData, NULL, parent); }
  327.  
  328.   Widget postBlocked ( const char     *msg, 
  329.                XtCallbackProc  okCB, 
  330.                XtCallbackProc  cancelCB, 
  331.                XtPointer       clientData,
  332.                char            *helpString,
  333.                VkSimpleWindow *parent = NULL)  { return postBlocked(msg, okCB, cancelCB, NULL, clientData, helpString, parent); }
  334.  
  335.   Widget postBlocked ( const char     *msg, 
  336.                XtCallbackProc  okCB, 
  337.                XtCallbackProc  cancelCB, 
  338.                XtCallbackProc  applyCB, 
  339.                XtPointer       clientData,
  340.                VkSimpleWindow *parent)  { return postBlocked(msg, okCB, cancelCB, applyCB, clientData, NULL, parent); }
  341.  
  342.  
  343.   Widget postBlocked ( const char *msg, 
  344.                Widget parent) { return postBlocked(msg, NULL, NULL, NULL, NULL, NULL, NULL, parent); }
  345.   
  346.   Widget postBlocked ( const char     *msg, 
  347.                const char     *helpString,                
  348.                Widget parent) { return postBlocked(msg, NULL, NULL, NULL, NULL, helpString, NULL, parent); }
  349.  
  350.   Widget postBlocked ( const char      *msg, 
  351.                XtCallbackProc   okCB, 
  352.                XtPointer        clientData,
  353.                Widget parent)  { return postBlocked(msg, okCB, NULL, NULL, clientData, NULL, NULL, parent); }
  354.  
  355.   Widget postBlocked ( const char      *msg, 
  356.                XtCallbackProc   okCB, 
  357.                XtPointer        clientData,
  358.                const char     *helpString,                
  359.                Widget parent)  { return postBlocked(msg, okCB, NULL, NULL, clientData, helpString, NULL, parent); }
  360.  
  361.  
  362.   Widget postBlocked ( const char     *msg, 
  363.                XtCallbackProc  okCB, 
  364.                XtCallbackProc  cancelCB, 
  365.                XtPointer       clientData,
  366.                Widget parent)  { return postBlocked(msg, okCB, cancelCB, NULL, clientData, NULL, NULL, parent); }
  367.  
  368.   Widget postBlocked ( const char     *msg, 
  369.                XtCallbackProc  okCB, 
  370.                XtCallbackProc  cancelCB, 
  371.                XtPointer       clientData,
  372.                char            *helpString,
  373.                Widget parent)  { return postBlocked(msg, okCB, cancelCB, NULL, clientData, helpString, NULL, parent); }
  374.  
  375.   Widget postBlocked ( const char     *msg, 
  376.                XtCallbackProc  okCB, 
  377.                XtCallbackProc  cancelCB, 
  378.                XtCallbackProc  applyCB, 
  379.                XtPointer       clientData,
  380.                Widget parent)  { return postBlocked(msg, okCB, cancelCB, applyCB, clientData, NULL, NULL, parent); }
  381.  
  382.     
  383.   // Doesn't return until choice has been made. Returns the user's choice
  384.  
  385.   VkDialogReason postAndWait ( const char      *message, 
  386.                    const char      *helpString,                
  387.                    VkSimpleWindow  *parent     = NULL);
  388.   
  389.   VkDialogReason postAndWait ( const char      *message, 
  390.                    VkSimpleWindow  *parent) { return postAndWait(message, NULL, parent); }
  391.  
  392.   VkDialogReason postAndWait ( const char      *message, 
  393.                    const char      *helpString,                
  394.                    Widget          parent);
  395.   
  396.   VkDialogReason postAndWait ( const char      *message, 
  397.                    Widget          parent) { return postAndWait(message, NULL, parent); }    
  398.  
  399.  
  400.   private:
  401.  
  402.     static void VkDialogMapped (Widget, XtPointer, XtPointer);
  403.     static void okXtCallback (Widget, XtPointer, XtPointer);
  404.     static void applyXtCallback (Widget, XtPointer, XtPointer);
  405.     static void cancelXtCallback (Widget, XtPointer, XtPointer);
  406.     static void helpXtCallback (Widget, XtPointer, XtPointer);
  407.  
  408.     static void handleWMDeleteCallback (Widget, XtPointer, XtPointer);
  409.  
  410.     Widget _widgetParent;
  411.     void help(const char *);
  412.     VkWidgetList  _widgets;
  413.  
  414.     Widget findDialog(Widget parent);
  415.  
  416.     VkDialog * getCacheInfo(Widget);
  417.  
  418.     Widget findValidParent(VkSimpleWindow *);
  419.  
  420.     char    *_nextTitle;
  421.     char    *_nextOKLabel, 
  422.             *_nextCancelLabel, 
  423.             *_nextApplyLabel;
  424.  
  425.     Boolean _centerMode;
  426.  
  427.     VkDialog     *_dialogList;
  428.  
  429.     void clearCache(Widget);
  430.  
  431.  
  432. };
  433.  
  434. #endif
  435.  
  436.  
  437.  
  438.